package com.net.wanjian.networkhospitalmanager.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.net.wanjian.networkhospitalmanager.R;
import com.net.wanjian.networkhospitalmanager.adapter.base.RecyclerBaseAdapter;
import com.net.wanjian.networkhospitalmanager.bean.Video.GetVideoListBean;
import com.net.wanjian.networkhospitalmanager.utils.DateUtil;

/**
 * Created by WJ on 2017/8/14.
 */

public class VoidListAdapterX extends RecyclerBaseAdapter<GetVideoListBean.VideoListBean.VideoBean, VoidListAdapterX.ViewHolderX> {

    public VoidListAdapterX(Context context) {
        super(context);
    }

    @Override
    public ViewHolderX onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.item_void_list, parent, false);
        return new ViewHolderX(view);
    }

    @Override
    public void onBindViewHolder(ViewHolderX holder, GetVideoListBean.VideoListBean.VideoBean item, int position) {
        Glide.with(context).load(item.getCoverURL()).placeholder(R.mipmap.ic_loading_325).into(holder.img_picture);
        holder.tv_ms.setText(item.getDescription());
        holder.tv_Duration.setText(DateUtil.secToTime((int) item.getDuration()));
        String createTime = item.getCreateTime();
        holder.tv_time.setText(DateUtil.dateFormat(createTime));
        holder.tv_title.setText(item.getTitle());
        holder.tv_classification.setText(item.getTags().split(",")[0]);
    }

    class ViewHolderX extends RecyclerView.ViewHolder {
        private ImageView img_picture;
        private TextView tv_ms;
        private TextView tv_time, tv_title, tv_classification, tv_Duration;

        public ViewHolderX(View itemView) {
            super(itemView);
            img_picture = (ImageView) itemView.findViewById(R.id.img_picture);
            tv_ms = (TextView) itemView.findViewById(R.id.tv_ms);
            tv_time = (TextView) itemView.findViewById(R.id.tv_time);
            tv_title = (TextView) itemView.findViewById(R.id.tv_title);
            tv_classification = (TextView) itemView.findViewById(R.id.tv_classification);
            tv_Duration = (TextView) itemView.findViewById(R.id.tv_Duration);
        }
    }
}
